$(function () {
    
/*---------------------- 运行区 ---------------------------------*/
    //设置输入正则判断
    judgeTheInput();
/*---------------------- 实现区 ---------------------------------*/
    //设置输入正则判断实现
    function judgeTheInput() {
        
        let $account = $("#accountInput");

        let $password = $("#passwordInput");

        let $wrong = $("<div>").css({
            "padding-left":"26px",
            "line-height":"18px",
            "color":"#CC0000",
            "font-size":"12px",
            "margin":"-15px 0 25px",
            "background":"url(../source/img/ico-error.png) no-repeat left center"
        }).attr("id","wrongDiv").text("帐号格式错误");

        $("div.loginMain input[type=text]").on("focus", function(){

            $(this).parent().css("border-color", "#3B78DD");
        });

        $("div.loginMain input[type=text]").on("blur", function(){

            $(this).parent().css("border-color", "#c5cddb");

            // if (this.value.length == 0) {
                
            //     return;
            // }

            if(this.id == "accountInput"){

                if (this.value.length == 0) {
                    
                    $wrong.remove();

                    return;
                }
                
                judgeTheAccount(this.value);

            }
        });

        function judgeTheAccount(text) {
            
            let ifPhone = /^1[35678][0-9]{9}$/.test(text);

            let ifMail = /^[0-9a-zA-Z][^@]{3,}$/.test(text);

            if(!ifPhone && !ifMail){

                $account.parent().css("border-color", "red");

                createWrong();

            }else{

                $wrong.remove();
            }

            function createWrong() {
                
               

                $password.parent().after($wrong);
            }


        }

        
    }

});
